package server.web.api.webuser;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import server.web.WebUser;

public class Heartbeat extends HttpServlet {
    private static final long serialVersionUID = 1278407046922005995L;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        resp.setContentType("text/plain");

        HttpSession se = req.getSession(false);
        if (se != null && se.getAttribute("user") != null) {
            WebUser user = (WebUser) se.getAttribute("user");
            user.heartbeat();
            resp.getWriter().print("true");
        } else {
            resp.getWriter().print("false");
        }
    }
}